package com.campusbackend.service.impl;

import com.campusbackend.entity.TeamMembers;
import com.campusbackend.mapper.TeamMembersMapper;
import com.campusbackend.service.TeamMembersService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

/**
 * <p>
 * 队伍成员表 服务实现类
 * </p>
 *
 * @author yezi
 * @since 2025-07-26
 */
@Service
public class TeamMembersServiceImpl extends ServiceImpl<TeamMembersMapper, TeamMembers> implements TeamMembersService {

    @Autowired
    private TeamMembersMapper teamMembersMapper;

    @Override
    public boolean updateMemberScore(Long teamId, Long studentId, BigDecimal score) {
        // 参数验证
        if (teamId == null || studentId == null || score == null) {
            return false;
        }
        
        // 分数范围验证（0-20分）
        if (score.compareTo(BigDecimal.ZERO) < 0 || score.compareTo(new BigDecimal("20")) > 0) {
            return false;
        }
        
        int result = teamMembersMapper.updateMemberScore(teamId, studentId, score);
        return result > 0;
    }
} 